/** 一定处于节点下 */

import { Tooltip } from "antd"
import { useMemoizedFn } from "ahooks"
import i18next from "i18next"
import styles from "./index.module.less"

type TestBtnProps = {
	testFn?: () => void
	tooltips?: string
}

export default function TestNodeBtn({
	testFn,
	tooltips = i18next.t("common.testByStep", { ns: "flow" }),
}: TestBtnProps) {
	const testNodeFn = useMemoizedFn(() => {
		testFn?.()
	})

	return (
		<Tooltip title={tooltips}>
			<svg
				width="20"
				height="20"
				viewBox="0 0 20 20"
				fill="none"
				xmlns="http://www.w3.org/2000/svg"
				onClick={testNodeFn}
				className={styles.testNode}
			>
				<path
					d="M2.5 10C2.5 10.9849 2.69399 11.9602 3.0709 12.8701C3.44781 13.7801 4.00026 14.6069 4.6967 15.3033C5.39314 15.9997 6.21993 16.5522 7.12987 16.9291C8.03982 17.306 9.01509 17.5 10 17.5C10.9849 17.5 11.9602 17.306 12.8701 16.9291C13.7801 16.5522 14.6069 15.9997 15.3033 15.3033C15.9997 14.6069 16.5522 13.7801 16.9291 12.8701C17.306 11.9602 17.5 10.9849 17.5 10C17.5 9.01509 17.306 8.03982 16.9291 7.12987C16.5522 6.21993 15.9997 5.39314 15.3033 4.6967C14.6069 4.00026 13.7801 3.44781 12.8701 3.0709C11.9602 2.69399 10.9849 2.5 10 2.5C9.01509 2.5 8.03982 2.69399 7.12987 3.0709C6.21993 3.44781 5.39314 4.00026 4.6967 4.6967C4.00026 5.39314 3.44781 6.21993 3.0709 7.12987C2.69399 8.03982 2.5 9.01509 2.5 10Z"
					stroke="#1C1D23"
					strokeOpacity="0.8"
					strokeWidth="1.5"
					strokeLinecap="round"
					strokeLinejoin="round"
				/>
				<path
					d="M7.5 6.27793V13.3888C7.49998 13.4679 7.52105 13.5456 7.56106 13.6138C7.60106 13.682 7.65854 13.7383 7.72756 13.7769C7.79658 13.8155 7.87465 13.8349 7.95371 13.8333C8.03277 13.8316 8.10996 13.8089 8.17731 13.7675L13.9549 10.212C14.0196 10.1723 14.0731 10.1166 14.1101 10.0503C14.1472 9.98401 14.1667 9.90933 14.1667 9.83338C14.1667 9.75743 14.1472 9.68274 14.1101 9.61646C14.0731 9.55017 14.0196 9.49448 13.9549 9.45472L8.17731 5.89928C8.10996 5.85784 8.03277 5.83512 7.95371 5.83347C7.87465 5.83182 7.79658 5.85129 7.72756 5.88988C7.65854 5.92847 7.60106 5.98477 7.56106 6.05299C7.52105 6.1212 7.49998 6.19885 7.5 6.27793Z"
					fill="#1C1D23"
					fillOpacity="0.8"
				/>
			</svg>
		</Tooltip>
	)
}
